<template>
	<view class="container">
		<view class="container-info">
			<view class="container-info-box">
				类型：
				<span>{{getValue(otherList,form.moreType)}}</span>
			</view>
		</view>
		<view class="container-info">
			<view class="container-info-box">
				时间：
				<span>{{form.eventTime}}</span>
			</view>
		</view>
		<view class="container-info" v-if="form.moreType === '1' || form.moreType === 1 ">
			<view class="container-info-box">
				类型：
				<span>{{getValue(radioList,form.type)}}</span>
			</view>
		</view>
		<view v-if="form.type === '1' || form.type === 1 " class="container-info">
			<view class="container-info-box">
				颜色：
				<span>{{getValue(colorList,form.color)}}</span>
			</view>
		</view>
		<view v-if="form.type === '0' || form.type === 0 " class="container-info">
			<view class="container-info-box">
				颜色：
				<span>{{getValue(colorsList,form.color)}}</span>
			</view>
		</view>
		<view v-if="form.type === '1' || form.type === 1 " class="container-info">
			<view class="container-info-box">
				形状：
				<span>{{getValue(shapeList,form.pottyState)}}</span>
			</view>
		</view>
		<view v-if="form.moreType === '0' || form.moreType === 0 " class="container-info">
			<view class="container-info-box">
				食物类型：
				<span>{{form.foodType}}</span>
			</view>
		</view>
		<view v-if="form.moreType === '0' || form.moreType === 0 " class="container-info">
			<view class="container-info-box">
				水量(杯)：
				<span>{{form.liquidQuantity}}</span>
			</view>
		</view>
		<view v-if="form.moreType === '0' || form.moreType === 0 " class="container-info">
			<view class="container-info-box">
				食量：
				<span>{{getValue(appetiteList,form.quantity)}}</span>
			</view>
		</view>
		<view class="container-info">
			<view class="container-info-box">
				照片：
				<view style="margin-top: 20rpx;">
					<LmageListView 
							:resourceUrls="form.img | resourceUrlFilter" />
					</view>
				</view>
		</view>
	</view>
</template>

<script>
	import {
		getMoreListInfoWeb
	} from './api/index.js'
	import recordMixin from './mixins/info.js'
		import LmageListView from '@/components/image-list-view.vue'
	import {
		formatDateByTimestamp
	} from '@/utils/utils.js'
	export default {
		mixins: [recordMixin],
		components: {
			// MultiMediaView,
			LmageListView
		},
		data() {
			return {
				form: {
					eventTime: formatDateByTimestamp(Date.now(), 'yyyy/mm/dd hh:MM:ss'),
					temperature: 36.5,
					emotion: 3,
					bodyState: 3,
					remark: '',
				},
				radiosList: [{
						name: '母乳',
					},
					{
						name: '配方奶',
					},
					{
						name: '水'
					}
				],
				otherList:[
					{
						name: '喂奶',
						value: '0',
					},{
						name: '换尿布',
						value: '1',
					}
				],
				appetiteList: [{
						name: '正常',
						value: '0',
					},
					{
						name: '量多',
						value: '2',
					},
					{
						name: '量少',
						value: '1',
					}
				],
				radioList: [
					{
						name: '小便',
						value: '0',
					},{
						name: '大便',
						value: '1',
					}
				],
				colorList: [{
						name: '正常',
						value: '0',
					},
					{
						name: '偏黑',
						value: '1',
					},
					{
						name: '偏绿',
						value: '2',
					},
					{
						name: '其他',
						value: '3',
					}
				],
				
				colorsList:[
					{
						name: '正常',
						value: '0',
					},
					{
						name: '偏黄',
						value: '1',
					},
				],
				
				shapeList: [{
						name: '正常',
						value: '0',
					},
					{
						name: '偏稀',
						value: '1',
					},
					{
						name: '偏硬',
						value: '2',
					}
				],
			}
		},
		filters: {
			resourceUrlFilter (value) {
				if (!value) {
					return []
				}
				return value.split('|');
			}
		},
		methods: {
			getValue(list,value) {
				return list.find(item => item.value * 1 === value * 1)?.name
			},
			getRecord() {
				console.log(this.recordId)
				if (this.$u.test.isEmpty(this.recordId)) {
					return;
				}
				uni.showLoading({})
				const params = {
					id: this.recordId,
					childId: this.defaultChildren.id
				}
				getMoreListInfoWeb(params).then(res => {
					uni.hideLoading()
					const { foodType, diet, quantity, liquidQuantity,img,type,moreType,color,pottyState} = res.data; 
					const eventTime = formatDateByTimestamp(res.data.eventTime, 'yyyy/mm/dd hh:MM:ss')
					const form = {
						pottyState,
						eventTime,
						foodType,
						diet,
						quantity,
						liquidQuantity,
						img,
						type,
						moreType,
						color,
						img
					};
					this.form = form
				})

			
			},
		}
	}
</script>

<style lang="scss" scoped>


</style>
